/*
 * @Author: 贺楠 1071780426@qq.com
 * @Date: 2024-04-03 16:39:17
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-04-08 10:24:38
 * @FilePath: \newMould_BHZ\src\components\environmentalMonitorManage\testingRecord\location\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export default {
    props: [
        "dialogVisible",
        "locationData"
    ],
    data() {
        return {
            visible: "",

            loading: false,

            dialogHeight: null,
            formData: null,
            map:null

        };
    },
    components: {

    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        locationData: {
            handler(newVal) {
                if (newVal) {
                  
                    this.formData = newVal;
                
                }
            },
            immediate: true,
        }
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        var that=this;
        setTimeout(()=>{
            that.map = new window.AMap.Map('locationMap', {
                zoom: 16,
                center: [this.formData.deviceLongitude,this.formData.deviceLatitude],
                viewMode: '3D'
            });
            let marker = new window.AMap.Marker({
                position: [this.formData.deviceLongitude,this.formData.deviceLatitude],//要展示marker的经度、纬度。数据格式就是数组里放入经纬度数据
                // icon: require("../../../public/img/bg/site.png"), //显示的图标
                // offset: [-16, -32],//图标偏移量，展示时会默认以图标的左上角为原点，不设置偏移量会导致地图放大缩小时造成图标偏移的情况，偏移量设置为图标宽度的负一半，负整个高度。
            })
            that.map.add(marker); 

        },500)



    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog1() {
            this.$emit("close1");
        },


    },
};